home *** CD-ROM | disk | FTP | other *** search
/ Dr. Windows 3 / dr win3.zip / dr win3 / PROGRAMR / OLE2BOOK.ZIP / CHAP12.ZIP / PATRON / PAGES.H < prev    next >
C/C++ Source or Header  |  1993-06-27  |  12KB  |  367 lines

  1. /*
  2.  * PAGES.H
  3.  * Modifications for Chapter 12
  4.  *
  5.  * Definitions and function prototypes for the Pages window control
  6.  * as well as the CPage class.
  7.  *
  8.  * Copyright (c)1993 Microsoft Corporation, All Rights Reserved
  9.  *
  10.  * Kraig Brockschmidt, Software Design Engineer
  11.  * Microsoft Systems Developer Relations
  12.  *
  13.  * Internet  :  kraigb@microsoft.com
  14.  * Compuserve:  >INTERNET:kraigb@microsoft.com
  15.  */
  16.  
  17.  
  18. #ifndef _PAGES_H_
  19. #define _PAGES_H_
  20.  
  21. //We need this for UICursorLoad and new-style cursors.
  22. #include <bttncur.h>
  23.  
  24.  
  25. //Versioning.
  26. #define VERSIONMAJOR                2
  27. #define VERSIONMINOR                0
  28. #define VERSIONCURRENT              0x00020000
  29.  
  30. //Classname
  31. #define SZCLASSPAGES                "pages"
  32.  
  33. #define HIMETRIC_PER_INCH           2540
  34. #define LOMETRIC_PER_INCH           254
  35. #define LOMETRIC_BORDER             60          //Border around page
  36.  
  37.  
  38. //Window extra bytes and offsets
  39. #define CBPAGESWNDEXTRA             (sizeof(LONG))
  40. #define PAGEWL_STRUCTURE            0
  41.  
  42.  
  43. //Time to break this stuff out into another file.
  44. #include "tenant.h"
  45.  
  46.  
  47. typedef struct __far tagTENANTLIST
  48.     {
  49.     DWORD       cTenants;
  50.     DWORD       dwIDNext;
  51.     } TENANTLIST, FAR *LPTENANTLIST;
  52.  
  53.  
  54. /*
  55.  * Persistent information we need to save for each tenant, which is done
  56.  * in the tenant list instead of with each tenant.  Since this is a small
  57.  * structure it's best not to blow another stream for it (overhead).
  58.  */
  59. typedef struct tagTENANTINFO
  60.     {
  61.     DWORD       dwID;
  62.     RECTL       rcl;
  63.     FORMATETC   fe;     //Excludes ptd
  64.     } TENANTINFO, FAR *LPTENANTINFO;
  65.  
  66.  
  67. #define SZSTREAMTENANTLIST        "Tenant List"
  68.  
  69.  
  70.  
  71.  
  72. /*
  73.  * Page class describing an individual page and what things it contains,
  74.  * managing an IStorage for us.
  75.  *
  76.  * A DWORD is used to identify this page as the name of the storage
  77.  * is the string form of this ID.  If we added a page every second,
  78.  * it would take 136 years to overrun this counter, so we can
  79.  * get away with saving it persistently.  I hope this software is
  80.  * obsolete by then.
  81.  */
  82.  
  83. class __far CPage
  84.     {
  85.     friend class CIOleUILinkContainer;
  86.  
  87.     private:
  88.         HWND        m_hWnd;             //Pages window, same as CPages.
  89.         DWORD       m_dwID;             //Persistent DWORD identifier
  90.         LPSTORAGE   m_pIStorage;        //Sub-storage for this page.
  91.         DWORD       m_cOpens;           //Calls to FOpen.
  92.  
  93.         class CPages FAR *m_pPG;        //Pages window
  94.  
  95.         DWORD       m_dwIDNext;
  96.         DWORD       m_cTenants;
  97.         HWND        m_hWndTenantList;   //Listbox that manages our tenant list
  98.  
  99.         UINT        m_iTenantCur;
  100.         LPTENANT    m_pTenantCur;
  101.  
  102.         UINT        m_uHTCode;          //Last hit-test on mouse move.
  103.         UINT        m_uSizingFlags;     //Restrictions on sizing motion.
  104.         BOOL        m_fTracking;        //Tracking resize?
  105.         RECTL       m_rclOrg;           //Original before tracking
  106.         RECTL       m_rcl;              //Tracking rectangle.
  107.         RECTL       m_rclBounds;        //Boundaries for size tracking.
  108.         HDC         m_hDC;              //Tracking hDC.
  109.  
  110.     protected:
  111.         BOOL         FTenantGet(UINT, LPTENANT FAR *, BOOL);
  112.         BOOL         FTenantAdd(UINT, DWORD, LPTENANT FAR *);
  113.         LPDATAOBJECT TransferObjectCreate(LPPOINTL);
  114.  
  115.         //PAGEMOUS.CPP
  116.         BOOL         FSelectTenantAtPoint(UINT, UINT);
  117.         UINT         TenantFromPoint(UINT, UINT, LPTENANT FAR *);
  118.         BOOL         DragDrop(UINT, UINT, UINT);
  119.  
  120.     public:
  121.         CPage(DWORD, HWND, class CPages FAR *);
  122.         ~CPage(void);
  123.  
  124.         DWORD       GetID(void);
  125.         BOOL        FOpen(LPSTORAGE);
  126.         void        Close(BOOL);
  127.         BOOL        Update(void);
  128.         void        Destroy(LPSTORAGE);
  129.         UINT        GetStorageName(LPSTR);
  130.  
  131.         void        Draw(HDC, int, int, BOOL, BOOL);
  132.  
  133.         BOOL        TenantCreate(TENANTTYPE, LPVOID, LPFORMATETC
  134.                         , LPPATRONOBJECT, DWORD);
  135.         BOOL        TenantDestroy(void);
  136.         BOOL        TenantClip(BOOL);
  137.         BOOL        FQueryObjectSelected(HMENU);
  138.         void        ActivateObject(UINT);
  139.         //CHAPTER12MOD
  140.         void        ShowObjectTypes(BOOL);
  141.         void        NotifyTenantsOfRename(LPSTR, LPMONIKER);
  142.         BOOL        FQueryLinksInPage(void);
  143.         //End CHAPTER12MOD
  144.  
  145.         //PAGEMOUSE.CPP
  146.         BOOL        OnRightDown(UINT, UINT, UINT);
  147.         BOOL        OnLeftDown(UINT, UINT, UINT);
  148.         BOOL        OnLeftDoubleClick(UINT, UINT, UINT);
  149.         BOOL        OnLeftUp(UINT, UINT, UINT);
  150.         void        OnNCHitTest(UINT, UINT);
  151.         BOOL        OnSetCursor(UINT);
  152.         void        OnMouseMove(UINT, int, int);
  153.     };
  154.  
  155. typedef CPage FAR * LPPAGE;
  156.  
  157.  
  158.  
  159. /*
  160.  * Structures to save with the document describing the device
  161.  * configuration and pages that we have.  This is followed by
  162.  * a list of DWORD IDs for the individual pages.
  163.  */
  164.  
  165. typedef struct __far tagDEVICECONFIG
  166.     {
  167.     DEVMODE     dm;
  168.     char        szDriver[CCHDEVICENAME];
  169.     char        szDevice[CCHDEVICENAME];
  170.     char        szPort[CCHDEVICENAME];
  171.     } DEVICECONFIG, FAR * LPDEVICECONFIG;
  172.  
  173.  
  174. typedef struct __far tagPAGELIST
  175.     {
  176.     DWORD       cPages;
  177.     DWORD       iPageCur;
  178.     DWORD       dwIDNext;
  179.     } PAGELIST, FAR *LPPAGELIST;
  180.  
  181.  
  182. //PAGEWIN.CPP
  183. LRESULT __export FAR PASCAL PagesWndProc(HWND, UINT, WPARAM, LPARAM);
  184. BOOL    __export FAR PASCAL AbortProc(HDC, int);
  185. BOOL    __export FAR PASCAL PrintDlgProc(HWND, UINT, WPARAM, LPARAM);
  186. void                        RectConvertMappings(LPRECT, HDC, BOOL);
  187.  
  188.  
  189.  
  190. class __far CPages : public CWindow
  191.     {
  192.     friend LRESULT __export FAR PASCAL PagesWndProc(HWND, UINT, WPARAM, LPARAM);
  193.     friend BOOL    __export FAR PASCAL PrintDlgProc(HWND, UINT, WPARAM, LPARAM);
  194.  
  195.     friend class CPage;
  196.     friend class CTenant;
  197.     friend class CDropTarget;
  198.     friend class CImpIOleClientSite;
  199.     friend class CImpIAdviseSink;
  200.  
  201.     protected:
  202.         LPPAGE      m_pPageCur;             //Current page we're viewing
  203.         UINT        m_iPageCur;
  204.         UINT        m_cPages;               //Number of pages
  205.  
  206.         HWND        m_hWndPageList;         //Listbox that manages our page list
  207.         HFONT       m_hFont;                //Page font.
  208.         BOOL        m_fSystemFont;          //Is m_hFont system object?
  209.  
  210.         UINT        m_cx;                   //Usable page size in LOMETRIC
  211.         UINT        m_cy;
  212.  
  213.         UINT        m_xMarginLeft;          //Unusable page margins, LOMETRIC
  214.         UINT        m_xMarginRight;
  215.         UINT        m_yMarginTop;
  216.         UINT        m_yMarginBottom;
  217.  
  218.         UINT        m_xPos;                 //Current viewport scroll position.
  219.         UINT        m_yPos;                 //both in *PIXELS*
  220.  
  221.         DWORD       m_dwIDNext;             //Next ID for a page.
  222.         LPSTORAGE   m_pIStorage;            //Root storage of document.
  223.  
  224.         UINT        m_cf;                   //Application clipboard format.
  225.         BOOL        m_fDirty;
  226.  
  227.         BOOL        m_fDragSource;          //Drag-drop source==target
  228.         BOOL        m_fMoveInPage;          //Only moving in same page
  229.         //CHAPTER12MOD
  230.         BOOL        m_fLinkAllowed;         //Can allow linking in drag-drop.
  231.         //End CHAPTER12MOD
  232.         POINTL      m_ptDrop;               //Where to move object to.
  233.  
  234.         BOOL        m_fDragRectShown;       //Is there a rect on the screen?
  235.         UINT        m_uScrollInset;         //Hit-test region for drag-drop
  236.         UINT        m_uScrollDelay;         //Time to wait before repeat
  237.         DWORD       m_dwTimeLast;           //Ticks on last DragOver
  238.         UINT        m_uHScrollCode;         //Left or right on scroll repeat?
  239.         UINT        m_uVScrollCode;         //Up or down on scroll repeat?
  240.         UINT        m_uLastTest;            //Last from UTestDroppablePoint
  241.  
  242.         //CHAPTER12MOD
  243.         BOOL        m_fShowTypes;           //Show Object active?
  244.